package day0516.interfaceDemo;


public class TestAnimal {
    public static void main(String[] args) throws InterruptedException {
        Object[]  obj=new Object[3];
        obj[0]=new Cat("小猫花花");
        obj[1]=new Cat("小猫大白");
        obj[2]=new Tree();
        while(true){
            for(Object o :obj){
                if(o instanceof Animal){
                    Animal a=(Animal)o;
                    a.eat();
                }
                if(o instanceof Plant){
                    Plant a=(Plant)o;
                    a.photosynthesis();
                }
            }
            Thread.sleep(900);
            System.out.println("------------------");
        }
    }
}
